﻿#pragma once


#include <vulkan/vulkan.hpp>
#include "Math/IntPoint.h"
#include "Math/Rect.h"

class ISytemWindowInterface
{
public:
    virtual ~ISytemWindowInterface() {};

    virtual uint64_t GetWindowID() const =0;

    virtual vk::SurfaceKHR CreateVkSurfaceKHR(vk::Instance Instance) =0;
    
    //get window content position in screen
    virtual SIntPoint GetContentPosition() const =0;

    //get window content size 
    virtual SIntPoint GetContentSize() const =0;

    virtual SIntPoint GetWindowSize() const=0;

    virtual void SetWindowSize(SIntPoint InSize) =0;

    virtual SIntPoint GetWindowPosition() const =0;

    virtual void SetWindowPosition(SIntPoint InPosition) =0;

    virtual void MoveToScreenCenter() =0;
    
    virtual void SetWindowTitle(const CString &InTitle) =0;

    virtual SRect GetScreenPlacableArea()=0;

    virtual bool IsMaximized() const =0;

    virtual void Maximize() =0;

    //check if window is
    //not minimized, maximized, full screen
    virtual bool IsNormalSizeAndPosition() const =0;

    virtual void Restore() =0;

    virtual bool IsMinimized() const =0;

    virtual void Minimize() =0;

    virtual bool IsFullScreen() const =0;

    virtual void FullScreen() =0;


    //show boder if window is normal/maximized
    virtual void ShowBorder() =0;
    //hide border if window is normal/maximized
    virtual void HideBorder() =0;
    //系统边框是否可见
    virtual bool IsBorderVisible() const =0;

    virtual void Show() =0;
    virtual void Hide() =0;
    virtual bool IsVisible() const =0;

    virtual void SetOpcity(float InOpacity) =0;

    //enable/disable this window
    //if disable, this window will not receive any input event
    virtual void EnableThisWindow(bool bEnable) =0;
    virtual bool IsThisWindowEnabled() const =0;

    //bring this window to front
    virtual void BringToFront()=0;

    //hide this window in taskbar
    virtual void HideInTaskbar()=0;

};

//对ISytemWindowInterface 的封装
//实现了自动创建/销毁窗口
class WHENGINE_API CSystemWindow
{
public:
    //构造时自动创建系统窗口
    CSystemWindow();

    //析构时自动销毁窗口
    ~CSystemWindow();

    //获取窗口ID
    uint64_t GetWindowID() const
    {
        return WindowInterface->GetWindowID();
    }

    //获取窗口内容位置
    SIntPoint GetContentPosition() const
    {
        return WindowInterface->GetContentPosition();
    }

    //获取窗口内容大小
    SIntPoint GetContentSize() const
    {
        return WindowInterface->GetContentSize();
    }

    //获取窗口大小
    SIntPoint GetWindowSize() const
    {
        return WindowInterface->GetWindowSize();
    }

    //设置窗口大小
    void SetWindowSize(SIntPoint InSize)
    {
        WindowInterface->SetWindowSize(InSize);
    }

    //获取窗口位置
    SIntPoint GetWindowPosition() const
    {
        return WindowInterface->GetWindowPosition();
    }

    //设置窗口位置
    void SetWindowPosition(SIntPoint InPosition)
    {
        WindowInterface->SetWindowPosition(InPosition);
    }

    //移动窗口到屏幕中心
    void MoveToScreenCenter()
    {
        WindowInterface->MoveToScreenCenter();
    }

    //设置窗口标题
    void SetWindowTitle(const CString &InTitle)
    {
        WindowInterface->SetWindowTitle(InTitle);
    }

    //获取屏幕可放置区域
    SRect GetScreenPlacableArea()
    {
        return WindowInterface->GetScreenPlacableArea();
    }

    //判断窗口是否最大化
    bool IsMaximized() const
    {
        return WindowInterface->IsMaximized();
    }

    //最大化窗口
    void Maximize()
    {
        WindowInterface->Maximize();
    }

    //判断窗口是否正常大小和位置
    bool IsNormalSizeAndPosition() const
    {
        return WindowInterface->IsNormalSizeAndPosition();
    }

    //恢复窗口
    void Restore()
    {
        WindowInterface->Restore();
    }

    //判断窗口是否最小化
    bool IsMinimized() const
    {
        return WindowInterface->IsMinimized();
    }

    //最小化窗口
    void Minimize()
    {
        WindowInterface->Minimize();
    }

    //判断窗口是否全屏
    bool IsFullScreen() const
    {
        return WindowInterface->IsFullScreen();
    }

    //全屏窗口
    void FullScreen()
    {
        WindowInterface->FullScreen();
    }

    //显示窗口边框
    void ShowBorder()
    {
        WindowInterface->ShowBorder();
    }

    //隐藏窗口边框
    void HideBorder()
    {
        WindowInterface->HideBorder();
    }

    //判断窗口边框是否可见
    bool IsBorderVisible() const
    {
        return WindowInterface->IsBorderVisible();
    }

    //显示窗口
    void Show()
    {
        WindowInterface->Show();
    }

    //隐藏窗口
    void Hide()
    {
        WindowInterface->Hide();
    }

    //判断窗口是否可见
    bool IsVisible() const
    {
        return WindowInterface->IsVisible();
    }

    //设置窗口透明度
    void SetOpcity(float InOpacity)
    {
        WindowInterface->SetOpcity(InOpacity);
    }

    //启用/禁用窗口
    void EnableThisWindow(bool bEnable)
    {
        WindowInterface->EnableThisWindow(bEnable);
    }

    //判断窗口是否启用
    bool IsThisWindowEnabled() const
    {
        return WindowInterface->IsThisWindowEnabled();
    }

    //将窗口置顶
    void BringToFront()
    {
        WindowInterface->BringToFront();
    }

    //在任务栏中隐藏窗口
    void HideInTaskbar()
    {
        WindowInterface->HideInTaskbar();
    }

    //获取窗口接口
    ISytemWindowInterface * GetSystemWindow()
    {
        return WindowInterface;
    }



protected:
    ISytemWindowInterface * WindowInterface=nullptr;
};